import { http } from '@/plugins/http'

export function genPagedLoader (url: string) {
  return ({ params, page, size, sorter }: any) => {
    const req = { page, size, ...(params || {}) }
    if (sorter) {
      Object.assign(req, { sort_by: sorter.prop, sort_order: sorter.asc ? 1 : -1 })
    }
    return http.get(url, { params: req })
  }
}
